from selenium.webdriver.common.by import By

from element_base import TargetBase, CommandBase
from tools import DriverTools


# 对象库层
class InitialTarget(TargetBase):
    def __init__(self):
        super().__init__()
        self.driver = DriverTools().OpenDriver()
        self.agree_btn = By.ID, "com.bjcsxq.chat.carfriend:id/tv_commit"
        self.know_btn = By.ID, "com.bjcsxq.chat.carfriend:id/tv_commit"
        self.login_btn = By.ID, "com.bjcsxq.chat.carfriend:id/tv_login"

    def agree_elemen(self):
        return TargetBase().target_element(self.agree_btn)

    def know_element(self):
        return TargetBase().target_element(self.know_btn)

    def login_element(self):
        return TargetBase().target_element(self.login_btn)


# 操作层
class InitialCommand(CommandBase):
    def __init__(self):
        self.initial_target = InitialTarget()

    def click_agree(self):
        self.initial_target.agree_elemen().click()

    def click_know(self):
        self.initial_target.know_element().click()

    def click_login(self):
        self.initial_target.login_element().click()


# 业务层
class InitialExecute():
    def __init__(self):
        self.initial_command = InitialCommand()

    def execute(self):
        self.initial_command.click_agree()
        self.initial_command.click_know()
        self.initial_command.click_login()
